/**
 * Created by Administrator on 2017/9/22.
 */
//头部样式变化
var username = sessionStorage.getItem('username');
var stopa=null;
$(document).on('touchmove',function(){
    stopa=$(document).scrollTop();
    if ( stopa>=20 ) {
        $('.header').addClass('stop');
    }else{
        $('.header').removeClass('stop');
    }
});
//轮播图
var swiper1 = new Swiper('.swiper1',{
    autoplay:2000,
    loop:true,
    autoplayDisableOnInteraction:false,
    speed:1000,
    pagination:'.swiper-pagination'
});
//淘宝头条
function AutoScroll(obj) {
    $(obj).find("ul:first").animate({
            marginTop: "-22px"
        },
        1000,
        function() {
            $(this).css({
                marginTop: "0px"
            }).find("li:first").appendTo(this);
        });
}
$(document).ready(function() {
    setInterval('AutoScroll(".demo")', 2000)
});
// 红色圈圈
setInterval(function(){
    $('.tag').attr('style','animation: none;');
    setTimeout(function(){
        $('.tag').attr('style','animation: dong 0.6s ease-in-out;');
    },1000)
},3000);
//时间倒计时
function GetRTime(){
    var EndTime = new Date('2017/09/30 09:00:00');
    var XianTime = new Date();
    var t = EndTime.getTime() - XianTime.getTime();

    t-=1000;
    var d = 0;
    var h = 0;
    var m = 0;
    var s = 0;
    if(t>=0){
        d = Math.floor(t/1000/60/60/24); //天数
        h = Math.floor(t/1000/60/60%24);//小时
        m = Math.floor(t/1000/60%60);   //分钟
        s = Math.floor(t/1000%60);      //秒
    }
    $('.tianshu').html(d);
    $('.xiaoshi').html(h);
    $('.fenzhong').html(m);
    $('.miaoshu').html(s);
}

setInterval(GetRTime,1000);
 //点击按钮组
 $('.anniu li').click(function(){
     var num = $(this).attr('index');
     sessionStorage.setItem('num',num);
     location.href = 'html/option.html';
 });
 // 点击购物车
    $('.t-che').click(function(){

    if(username){
        location.href = 'html/shopping.html';
    }else{
        location.href = 'html/login.html';
    }
});